<?php
	if($_POST['action'] == 'user_vote')
	{
		if($_SESSION['userid'] > 0)
		{
			if($_POST['stars'] > 0)
			{
				if($_POST['vote_for'] != $_SESSION['userid'])
				{
					$error['user_vote'] = postUserVote($_SESSION['userid'], $_POST['vote_for'], $_POST['stars']);
					if($error['user_vote'] == 1)
					{ calculateRating(); }
				}
			}
		}
		else
		{
			$error['user_vote'] = 'You must be loged in to vote';
		}
	}
?>
<form name="user_vote<?php echo $user['id']; ?>" id="user_vote<?php echo $user['id']; ?>" method="post">
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td>
			<ul class="star-rating" onClick="document.getElementById('user_vote<?php echo $user['id']; ?>').submit();">
				<li class="current-rating" style="width:<?php echo round(($user['avg']/5)*100); ?>%;">Currently 3/5 Stars.</li>
				<li onMouseOver="document.getElementById('stars<?php echo $user['id']; ?>').value=1;"><a href="?menu=<?php echo $_GET['menu']; ?>&amp;com=<?php echo $_GET['com']; ?>" title="1 star out of 5" class="one-star">1</a></li>
				<li onMouseOver="document.getElementById('stars<?php echo $user['id']; ?>').value=2;"><a href="?menu=<?php echo $_GET['menu']; ?>&amp;com=<?php echo $_GET['com']; ?>" title="2 stars out of 5" class="two-stars">2</a></li>
				<li onMouseOver="document.getElementById('stars<?php echo $user['id']; ?>').value=3;"><a href="?menu=<?php echo $_GET['menu']; ?>&amp;com=<?php echo $_GET['com']; ?>" title="3 stars out of 5" class="three-stars">3</a></li>
				<li onMouseOver="document.getElementById('stars<?php echo $user['id']; ?>').value=4;"><a href="?menu=<?php echo $_GET['menu']; ?>&amp;com=<?php echo $_GET['com']; ?>" title="4 stars out of 5" class="four-stars">4</a></li>
				<li onMouseOver="document.getElementById('stars<?php echo $user['id']; ?>').value=5;"><a href="?menu=<?php echo $_GET['menu']; ?>&amp;com=<?php echo $_GET['com']; ?>" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			<input type="hidden" name="action" value="user_vote">
			<input type="hidden" name="stars" id="stars<?php echo $user['id']; ?>" value="0">
			<input type="hidden" name="vote_for" value="<?php echo $user['id']; ?>">
		</td>
	</tr>
</table>
</form>
